// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/base/api/MessageApi'

import OneClass from '@api/base/model/MessageDto'
import DelClass from '@api/base/model/MessageDeleteReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  validOne(one) {
    return one.id
  },
  async getOne({ id }, TIP = '查询消息') {
    const DTO = CORE.grpcDTO(OneClass, { id })
    const resp = await CORE.grpc(TIP, CLIENT, 'messageDetail', DTO)
    return resp
  },

  // —————————————————————————————— 删 —————————————————————————————— //

  async del({ id }, TIP = '删除消息') {
    const DTO = CORE.grpcDTO(DelClass, { ids: id })
    await CORE.grpc(TIP, CLIENT, 'messageDelete', DTO)
    return CORE.grpcOK(TIP)
  },

  // —————————————————————————————— 通过 —————————————————————————————— //

  pass(one) {
    one.id = one.nextId
  },

  // —————————————————————————————— 拒绝 —————————————————————————————— //

  rej(one) {
    one.id = one.prevId
  },
}
